﻿#include "global.h"
#include "coupler/coupler.h"
#include "plugin_export.h"
#include "plugin_typedef.h"
#include "plugin_info_inl.c"

#include <stdio.h>

int authCode = 0;

int LoadingInfo(int session) {
    authCode = Api_Initialize(session, infoJsonStr);
    return authCode;
}

int EventInit(char* path) {
    Api_SetFatal(authCode);
    Api_AppendLogs(authCode, "C++ Demo EventInit");
    return RET_TYPE_IGNORE;
}

int EventEnable() {
    return RET_TYPE_IGNORE;
}

int EventStop(int type) {
    return RET_TYPE_IGNORE;
}

int EventLogin(LPCSTR robotWxid, LPCSTR robotName, int type, LPCSTR msg) {
    return RET_TYPE_IGNORE;
}

int EventGroupMsg(LPCSTR robotWxid, int type, LPCSTR fromWxid, LPCSTR fromName, LPCSTR finalFromWxid, LPCSTR finalFromName, LPCSTR toWxid, LPCSTR msg) {
    return RET_TYPE_IGNORE;
}

int EventFriendMsg(LPCSTR robotWxid, int type, LPCSTR fromWxid, LPCSTR fromName, LPCSTR toWxid, LPCSTR msg) {
    if (type == MSG_TYPE_TEXT) {
        CHAR buffer[2048];
        snprintf(buffer, sizeof(buffer), "Received message \"%s\" from %s", msg, fromName);
        Api_SendTextMsg(authCode, robotWxid, fromWxid, buffer);
        Api_AppendLogs(authCode, buffer);
    }
    return RET_TYPE_IGNORE;
}

int EventReceivedTransfer(LPCSTR robotWxid, LPCSTR fromWxid, LPCSTR fromName, LPCSTR toWxid, LPCSTR money, LPCSTR jsonMsg) {
    return RET_TYPE_IGNORE;
}

int EventScanCashMoney(LPCSTR robotWxid, LPCSTR payWxid, LPCSTR payName, LPCSTR money, LPCSTR jsonMsg) {
    return RET_TYPE_IGNORE;
}

int EventFriendVerify(LPCSTR robotWxid, LPCSTR fromWxid, LPCSTR fromName, LPCSTR toWxid, LPCSTR jsonMsg) {
    return RET_TYPE_IGNORE;
}

int EventContactsChange(LPCSTR robotWxid, int type, LPCSTR fromWxid, LPCSTR fromName, LPCSTR msg) {
    return RET_TYPE_IGNORE;
}

int EventGroupMemberAdd(LPCSTR robotWxid, LPCSTR fromWxid, LPCSTR fromName, LPCSTR jsonMsg) {
    return RET_TYPE_IGNORE;
}

int EventGroupMemberDecrease(LPCSTR robotWxid, LPCSTR fromWxid, LPCSTR fromName, LPCSTR jsonMsg) {
    return RET_TYPE_IGNORE;
}

int EventSysMsg(LPCSTR robotWxid, int type, LPCSTR jsonMsg) {
    return RET_TYPE_IGNORE;
}

void Menu() {
    MessageBoxA(NULL, "Hello!", "Menu", MB_OK);
}
